package com.addplus.townmall.server.api.mapper.town;

import com.addplus.townmall.server.api.model.town.Floor;
import com.addplus.townmall.server.api.model.town.expand.FloorExpand;
import com.addplus.townmall.server.api.model.town.expand.FloorImageContextExpand;
import com.addplus.townmall.server.api.model.town.expand.FloorShopExpand;
import com.addplus.townmall.server.api.utils.BaseAddMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 楼层表 Mapper 接口
 * </p>
 *
 * @author zhangjiehang
 * @since 2018-08-27
 */
public interface FloorMapper extends BaseAddMapper<Floor> {

    @Select("SELECT f.*, ft.id as floor_type\n" +
            "from floor f,floor_type ft where f.more_skip_type=ft.id and f.is_delete = 0 ORDER BY f.sort")
    List<FloorExpand> getAllFloor();
    @Select("SELECT f.id,f.name,f.display_name,f.more_name,f.sort,f.more_skip_type,ft.name as type_name,f.more_skip_url from floor f LEFT JOIN floor_type ft on ft.id=f.more_skip_type where f.is_delete=0 ORDER BY f.gmt_modified DESC")
    List<FloorExpand> getAllFloorPage(IPage page);

    @Select("SELECT fm.id,f.name as floor_name,fm.img,fm.`name`,fm.skip_type,fm.skip_url,fm.sort from floor f LEFT JOIN floor_image_context fm on f.id=fm.floor_id where fm.is_delete=0 AND (f.more_skip_type=1 or f.more_skip_type=6) ORDER BY fm.gmt_modified DESC")
    List<FloorImageContextExpand> getAllFloorImage(IPage page);

    @Select("SELECT f.id,f.`name` FROM floor f where (f.more_skip_type=1 or f.more_skip_type=6)AND f.is_delete=0")
    List<Floor> getAllFloorNameForImage();

    @Select("SELECT f.id,f.`name`,f.more_skip_type FROM floor f where f.more_skip_type!=1 AND f.more_skip_type!=6 AND f.is_delete=0")
    List<Floor> getAllFloorNameForShop();

    @Select("SELECT f.`name` as floor_name,f.more_skip_type,fs.id,fs.shop_id,fs.sort,fs.gmt_modified from floor f LEFT JOIN floor_shop fs on f.id=fs.floor_id where fs.is_delete=0 AND f.more_skip_type!=1 AND f.more_skip_type!=6 ORDER BY fs.gmt_modified DESC")
    List<FloorShopExpand> getAllFloorShop(IPage page);
}
